package day06;

import java.lang.reflect.Array;

//方法的演示
public class MethodDemo {
    public static void main(String[] args) {
        say();
        System.out.println("继续执行");
        sayHi("zwt");
        System.out.println("继续执行");
        sayHello("zwt", 21);
        sayHello("zhangdada",35);
        double a = getNum();//getNum（）的值就是return后面那个数
        System.out.println(a);
        int b = plus(2, 3);
        System.out.println(b);
        int z = 2, i = 4;
        int c = plus(z, i);
        System.out.println(c);
        int[] e = testArray(5,30);
        System.out.println("数组的长度为：" + e.length);
        System.out.println("继续执行");
        int[] r = testArray(6,100);
        System.out.println("第一个数组元素的值为："+r[0]);
        System.out.println("继续执行...");
        int[] t = testArray(8,80);
        for (int i1 = 0; i1 < t.length; i1++) {
            System.out.println(t[i1]);
        }
        aMethod();
        System.out.println(444);
    }

    public static void say() {
        System.out.println("大家好，我叫zwt，今年21岁了");
    }

    public static void sayHi(String name) {
        System.out.println("大家好，我叫" + name + ",今年21岁了");
    }

    public static void sayHello(String name, int age) {
        if(age>30){
            return;
        }
        System.out.println("大家好，我叫" + name + "," + "今年" + age + "岁了");
    }

    public static double getNum() {
        return 3.14;
    }

    public static int plus(int z, int i) {
        int num = z + i;
        return num;
    }

    public static int[] testArray(int len,int max) {
        int[] arr = new int[len];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = (int) (Math.random() * max);
            System.out.println(arr[i]);
        }
        return arr;
    }
    public static void aMethod(){
        System.out.println(111);
        bMethod();
        System.out.println(222);
    }
    public static void bMethod(){
        System.out.println(333);
    }

}
